<?php

/**

 * 继承是否登录控制器

 */

namespace Custom\Controller;

use Think\Controller;

class UserController extends Controller {



    function __construct()

    {

        parent::__construct();

        $this->M_company = M('Company');

        $this->M_account = M('Account');

        $this->c_id = session('c_id');

        $this->is_son = session('is_son');

        $this->account_id = session('account_id');

        $this->s_id = session('s_id');

//        $company['company_name'] = session('company_name');

//        $company['company_logo'] = session('company_logo');

//        $this->assign('company',$company);

        if($this->c_id == '') $this->error('没有登录',U('/Custom/login'));

        $this->user_jur();

    }

    function user_jur(){

        $list = $this->M_account->find($this->account_id);

        if($list['is_son'] == 0){

            $account_info = $this->M_account->join('as a left join sp_role as p ON a.role_id = p.role_id')->find($this->account_id);

        }else{

            $account_info = $this->M_account->join('as a left join sp_role_son as p ON a.role_id = p.role_id')->find($this->account_id);

        }

        if($account_info){

            $company = $this->M_company->find($account_info['c_id']);

            $this->assign('title',$company['company_name']);

            $this->assign('company',$company);

        }

       if(!stristr($account_info['role_auth_ac'],CONTROLLER_NAME)){

           die($this->error(L("noquanxian").'！',U('store/selStore')));

       }

    }

    /**

     * 分页

     */

    protected function is_page($count){

        $page  = new \Think\Page($count,16);

        $page->rollPage=5;

        $page->setConfig('first', L("page_first"));

        $page->setConfig('last', L("page_last"));

        $page->lastSuffix = false;

        $show  = $page->show();

        $this->assign('page',$show);

        return $page;

    }

    

}